package com.itheima.homework5;

import java.util.HashMap;

public class Times {
    public static void main(String[] args) {
        String s = "wo ai heima wo ai java wo yao hao hao xue xi java";
        String[] s1 = s.split(" ");
        HashMap<String,Integer> hm = new HashMap<>();
        for (String s2 : s1) {
           /* if(!hm.containsKey(s2)){
                hm.put(s2,1);
            }else {
                hm.put(s2,hm.get(s2)+1);
            }*/
           hm.put(s2,hm.containsKey(s2)?hm.get(s2)+1:1);
        }
        hm.forEach((k,v)-> System.out.print(k+"("+v+")"));
    }
}
